package com.video.Controller;

import com.video.entity.Admin;
import com.video.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("admin")
public class AdminController {
    @Autowired
    public AdminService adminService;

    @RequestMapping("loginView")
    public String login() {
        return "/behind/login.jsp";
    }

    @RequestMapping("login")
    @ResponseBody
    public String login(Admin admin, HttpSession session){
        System.out.println(admin);
        Admin admin1 = adminService.selectByAdmin(admin);
        String username = admin.getUsername();
        if(admin1 != null){
            session.setAttribute("userName",username);
            return "success";
        }else {
            return null;
        }
//        return "/behind/videoList.jsp";
    }
}
